package de.baumann.browser.present.gg

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.gg.Morgage
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.gg.IMortgageRecordsView
import de.baumann.browser.model.getPledgeLog
import de.baumann.browser.model.morgageRecord
import de.baumann.browser.utils.getUser

class MortgageRecordsPresenter : BasePresenter<IMortgageRecordsView>() {
    fun a01(address:String) {
        var a = address
        if (address.startsWith("odx")){
            a = "0${address.substring(2)}"
        }
        morgageRecord(a)
                .subscribe(object : OdinObserver<List<Morgage>>(view) {
                    override fun onSuccess(data: List<Morgage>?) {
                        if (data != null) {
                            view.setList(data)
                        }
                    }
                })
    }

    fun a02(id: String) {
        getPledgeLog(id)
                .subscribe(object : OdinObserver<List<Morgage>>(view) {
                    override fun onSuccess(data: List<Morgage>?) {
                        if (data != null) {
                            view.setList(data)
                        }
                    }
                })
    }
}